#!/bin/bash
set -e  # 当任何命令失败时，自动退出脚本

work_dir="/media/adt/T7/ZWH/docker/files/data/motion"
data_path="$work_dir/datasets"
split_ratio="10,0,0" #一个包内train:test:val
val_datasets="__001,__2023-05-28-16-59-15_filter5-CarssAndTruckss,__2023-05-28-16-16-03_filter3-Cars,__2025-04-02-10-28-13_0_filter9_pedsAndcars,__2025-04-26-08-54-34_filter0_surround" #一个包内train:test:val
#split_ratio="0,0,10" #一个包内train:test:val
sweeps=10 #n个历史帧

# 封装命令执行和错误处理的函数
run_command() {
    local cmd="$1"
    local dsc="$2"
    echo "Running: $cmd"
    eval $cmd
    if [ $? -ne 0 ]; then
        echo "$dsc 运行失败，停止执行！！！"
        exit 1
    else
      echo "$dsc 运行成功。"
    fi
}


#####
# 添加脚本规则:
# run_command "python 脚本 参数列表"  "功能描述”
#####

echo "run2.sh 开始处理 $data_path"

### 格式转换
run_command "python reformat.py --data-path '$data_path'" "格式转换"

# 数据划分
run_command "python split_datasets.py --data-path '$data_path' --split '$split_ratio' --val_datasets '$val_datasets'"  "数据划分"

## 数据划分
run_command "python dataset2pkl.py --data-path '$data_path' --sweeps '$sweeps'"  "pkl生成"

echo "处理完毕"
